#!/usr/bin/env sh

COLOR=#00CED1

while read -r WIFI_STATE WIFI_CONNECTION ; do
  if [ "${WIFI_STATE}" == "connected" ]; then
    ICON="\Uf05a9"
    SIGNEL=$(nmcli -t -f ACTIVE,SIGNAL dev wifi | grep "^yes" | awk -F ':' '{print $2}')%
  elif [ "${WIFI_STATE}" == "disconnected" ]; then
    ICON="\Uf05aa"
  else
    ICON="\Uf16c5"
  fi
  WIFI_RESULT="${ICON} ${SIGNEL} ${WIFI_CONNECTION}"${WIFI_RESULT:+ ${WIFI_RESULT}}
done < <(nmcli -t dev status | grep ":wifi:" | awk -F ':' '{print $3,$4}')

while read -r ETHERNET_STATE ETHERNET_CONNECTION ; do
  if [ "${ETHERNET_STATE}" == "connected" ]; then
    ICON="\Uf0c53"
  elif [ "${ETHERNET_STATE}" == "disconnected" ]; then
    ICON="\Uf0c9b"
  else
    ICON="\Uf015b"
  fi
  ETHERNET_RESULT="${ICON} ${ETHERNET_CONNECTION}"${ETHERNET_RESULT:+ ${ETHERNET_RESULT}}
done < <(nmcli -t dev status | grep ":ethernet:" | awk -F ':' '{print $3,$4}')

echo -e "${WIFI_RESULT} ${ETHERNET_RESULT}\n\n${COLOR}"
